package com.lims.landInfo.dao;

import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

import javacommon.base.*;

import cn.org.rapid_framework.page.*;

import com.lims.landInfo.model.*;
import com.lims.landInfo.vo.query.*;

/**
 * @author zzh
 * @version 1.0
 * @since 1.0
 */@Repository @SuppressWarnings("unchecked")
public class DisposalDao extends BaseHibernateDao<Disposal,java.lang.String>{
	
	public Class getEntityClass() {
		return Disposal.class;
	}
	
	public Page findPage(DisposalQuery query) {
        //XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接 
        // [column] 为PageRequest的属性
		String sql = "select t from Disposal t where 1=1 "
			  	+ "/~ and t.sno = {sno} ~/"
			  	+ "/~ and t.landno = {landno} ~/"
			  	+ "/~ and t.corpName = {corpName} ~/"
			  	+ "/~ and t.restType = {restType} ~/"
				+ "/~ and t.restDate >= {restDateBegin} ~/"
				+ "/~ and t.restDate <= {restDateEnd} ~/"
			  	+ "/~ and t.scale = {scale} ~/"
			  	+ "/~ and t.restLandNum = {restLandNum} ~/"
			  	+ "/~ and t.sellNum = {sellNum} ~/"
			  	+ "/~ and t.sellArea = {sellArea} ~/"
			  	+ "/~ and t.shareNum = {shareNum} ~/"
			  	+ "/~ and t.shareArea = {shareArea} ~/"
			  	+ "/~ and t.rentNum = {rentNum} ~/"
			  	+ "/~ and t.rentArea = {rentArea} ~/"
			  	+ "/~ and t.appropriateNum = {appropriateNum} ~/"
			  	+ "/~ and t.appropriateArea = {appropriateArea} ~/"
			  	+ "/~ and t.manageNum = {manageNum} ~/"
			  	+ "/~ and t.manageArea = {manageArea} ~/"
			  	+ "/~ and t.rootNum = {rootNum} ~/"
			  	+ "/~ and t.rootArea = {rootArea} ~/"
			  	+ "/~ and t.subordinateNum = {subordinateNum} ~/"
			  	+ "/~ and t.subordinateArea = {subordinateArea} ~/"
			  	+ "/~ and t.persistNum = {persistNum} ~/"
			  	+ "/~ and t.persistAre = {persistAre} ~/"
			  	+ "/~ and t.restNum = {restNum} ~/"
			  	+ "/~ and t.restArea = {restArea} ~/"
			  	+ "/~ and t.restCause = {restCause} ~/"
			  	+ "/~ and t.noRestNum = {noRestNum} ~/"
			  	+ "/~ and t.noRestArea = {noRestArea} ~/"
			  	+ "/~ and t.noRestCause = {noRestCause} ~/"
			  	+ "/~ and t.changeType = {changeType} ~/"
			  	+ "/~ and t.oldno = {oldno} ~/"
			  	+ "/~ and t.oldContent = {oldContent} ~/"
			  	+ "/~ and t.describe = {describe} ~/"
				+ "/~ and t.landDate >= {landDateBegin} ~/"
				+ "/~ and t.landDate <= {landDateEnd} ~/"
				+ "/~ and t.createDate >= {createDateBegin} ~/"
				+ "/~ and t.createDate <= {createDateEnd} ~/"
				+ " order by t.sno asc ";

        //生成sql2的原因是为了不喜欢使用xsqlbuilder的同学，请修改生成器模板，删除本段的生成
        StringBuilder sql2 = new StringBuilder("select t from Disposal t where 1=1 ");
        if(isNotEmpty(query.getObjid())) {
            sql2.append(" and  t.objid = :objid ");
        }
        if(isNotEmpty(query.getSno())) {
            sql2.append(" and  t.sno = :sno ");
        }
        if(isNotEmpty(query.getLandno())) {
            sql2.append(" and  t.landno = :landno ");
        }
        if(isNotEmpty(query.getCorpName())) {
            sql2.append(" and  t.corpName = :corpName ");
        }
        if(isNotEmpty(query.getRestType())) {
            sql2.append(" and  t.restType = :restType ");
        }
        if(isNotEmpty(query.getRestDateBegin())) {
            sql2.append(" and  t.restDate >= :restDateBegin ");
        }
        if(isNotEmpty(query.getRestDateEnd())) {
            sql2.append(" and  t.restDate <= :restDateEnd ");
        }
        if(isNotEmpty(query.getScale())) {
            sql2.append(" and  t.scale = :scale ");
        }
        if(isNotEmpty(query.getRestLandNum())) {
            sql2.append(" and  t.restLandNum = :restLandNum ");
        }
        if(isNotEmpty(query.getSellNum())) {
            sql2.append(" and  t.sellNum = :sellNum ");
        }
        if(isNotEmpty(query.getSellArea())) {
            sql2.append(" and  t.sellArea = :sellArea ");
        }
        if(isNotEmpty(query.getShareNum())) {
            sql2.append(" and  t.shareNum = :shareNum ");
        }
        if(isNotEmpty(query.getShareArea())) {
            sql2.append(" and  t.shareArea = :shareArea ");
        }
        if(isNotEmpty(query.getRentNum())) {
            sql2.append(" and  t.rentNum = :rentNum ");
        }
        if(isNotEmpty(query.getRentArea())) {
            sql2.append(" and  t.rentArea = :rentArea ");
        }
        if(isNotEmpty(query.getAppropriateNum())) {
            sql2.append(" and  t.appropriateNum = :appropriateNum ");
        }
        if(isNotEmpty(query.getAppropriateArea())) {
            sql2.append(" and  t.appropriateArea = :appropriateArea ");
        }
        if(isNotEmpty(query.getManageNum())) {
            sql2.append(" and  t.manageNum = :manageNum ");
        }
        if(isNotEmpty(query.getManageArea())) {
            sql2.append(" and  t.manageArea = :manageArea ");
        }
        if(isNotEmpty(query.getRootNum())) {
            sql2.append(" and  t.rootNum = :rootNum ");
        }
        if(isNotEmpty(query.getRootArea())) {
            sql2.append(" and  t.rootArea = :rootArea ");
        }
        if(isNotEmpty(query.getSubordinateNum())) {
            sql2.append(" and  t.subordinateNum = :subordinateNum ");
        }
        if(isNotEmpty(query.getSubordinateArea())) {
            sql2.append(" and  t.subordinateArea = :subordinateArea ");
        }
        if(isNotEmpty(query.getPersistNum())) {
            sql2.append(" and  t.persistNum = :persistNum ");
        }
        if(isNotEmpty(query.getPersistAre())) {
            sql2.append(" and  t.persistAre = :persistAre ");
        }
        if(isNotEmpty(query.getRestNum())) {
            sql2.append(" and  t.restNum = :restNum ");
        }
        if(isNotEmpty(query.getRestArea())) {
            sql2.append(" and  t.restArea = :restArea ");
        }
        if(isNotEmpty(query.getRestCause())) {
            sql2.append(" and  t.restCause = :restCause ");
        }
        if(isNotEmpty(query.getNoRestNum())) {
            sql2.append(" and  t.noRestNum = :noRestNum ");
        }
        if(isNotEmpty(query.getNoRestArea())) {
            sql2.append(" and  t.noRestArea = :noRestArea ");
        }
        if(isNotEmpty(query.getNoRestCause())) {
            sql2.append(" and  t.noRestCause = :noRestCause ");
        }
        if(isNotEmpty(query.getChangeType())) {
            sql2.append(" and  t.changeType = :changeType ");
        }
        if(isNotEmpty(query.getOldno())) {
            sql2.append(" and  t.oldno = :oldno ");
        }
        if(isNotEmpty(query.getOldContent())) {
            sql2.append(" and  t.oldContent = :oldContent ");
        }
        if(isNotEmpty(query.getDescribe())) {
            sql2.append(" and  t.describe = :describe ");
        }
        if(isNotEmpty(query.getLandDateBegin())) {
            sql2.append(" and  t.landDate >= :landDateBegin ");
        }
        if(isNotEmpty(query.getLandDateEnd())) {
            sql2.append(" and  t.landDate <= :landDateEnd ");
        }
        if(isNotEmpty(query.getCreateDateBegin())) {
            sql2.append(" and  t.createDate >= :createDateBegin ");
        }
        if(isNotEmpty(query.getCreateDateEnd())) {
            sql2.append(" and  t.createDate <= :createDateEnd ");
        }
        if(isNotEmpty(query.getSortColumns())) {
            sql2.append(" order by :sortColumns ");
        }	
        
		return pageQuery(sql,query);
	}
	

}
